﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure.StorageClient;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.ServiceRuntime;

namespace BasicClasses
{
    public class EnderecoContext : TableServiceContext
    {
        
        private static CloudStorageAccount storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
        private static string tableName = RoleEnvironment.GetConfigurationSettingValue("EnderecoTable");
        
        public EnderecoContext() : base(storageAccount.TableEndpoint.AbsoluteUri, storageAccount.Credentials) 
        {
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
            tableClient.CreateTableIfNotExist(tableName);
        }

        public IQueryable<Endereco> Enderecos
        { 
            get 
            { 
                return this.CreateQuery<Endereco>(tableName); 
            } 
        
        }
    }
}
